﻿using Lhz.Data;
using Lhz.InternetService;
using Lhz.Sc.Entity.Database;
using Lhz.Test.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace Lhz.Sc.Test.LhzScService
{
    [TestClass]
    public class UnitTestApplication
    {
        [TestMethod]
        public void ApplicationServiceTestMethodCommon()
        {
            var application = TestEntityBuilder.BuildApplication();
            var dst = new ServiceCrudTester<Guid, Application>(TestConst.ServiceApplicationUrl);
            var changes = new Dictionary<string, object>();
            changes.Add("Name", "Name");
            changes.Add("Description", "Description");
            dst.CrudTest(application, application.Guid, changes);
        }

        [TestMethod]
        public void ApplicationServiceTestMethodQueryByPagination()
        {
            var si = new ServiceInvoker(typeof(Pagination), typeof(Application));
            var arguments = new object[] { new Pagination() { Index = 1, Size = 10 }, null };
            var applications = si.Invoke<Application[]>(TestConst.ServiceApplicationUrl, "QueryByPagination", arguments);
            Assert.IsTrue((arguments[0] as Pagination).Count == applications.Length);
        }
    }
}
